package com.fengpb.friday.conductor.core.execution.mapper;

import com.fengpb.friday.conductor.common.metadata.run.Workflow;
import com.fengpb.friday.conductor.common.metadata.task.TaskDef;
import com.fengpb.friday.conductor.common.metadata.workflow.WorkflowDef;
import com.fengpb.friday.conductor.common.metadata.workflow.WorkflowTask;
import com.fengpb.friday.conductor.core.execution.DeciderService;

import java.util.Map;

public class TaskMapperContext {

    private WorkflowDef workflowDefinition;

    private Workflow workflowInstance;

    private TaskDef taskDefinition;

    private WorkflowTask taskToSchedule;

    private Map<String, Object> taskInput;

    private String taskId;

    private DeciderService deciderService;

    public WorkflowDef getWorkflowDefinition() {
        return workflowDefinition;
    }

    public void setWorkflowDefinition(WorkflowDef workflowDefinition) {
        this.workflowDefinition = workflowDefinition;
    }

    public Workflow getWorkflowInstance() {
        return workflowInstance;
    }

    public void setWorkflowInstance(Workflow workflowInstance) {
        this.workflowInstance = workflowInstance;
    }

    public TaskDef getTaskDefinition() {
        return taskDefinition;
    }

    public void setTaskDefinition(TaskDef taskDefinition) {
        this.taskDefinition = taskDefinition;
    }

    public WorkflowTask getTaskToSchedule() {
        return taskToSchedule;
    }

    public void setTaskToSchedule(WorkflowTask taskToSchedule) {
        this.taskToSchedule = taskToSchedule;
    }

    public Map<String, Object> getTaskInput() {
        return taskInput;
    }

    public void setTaskInput(Map<String, Object> taskInput) {
        this.taskInput = taskInput;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public DeciderService getDeciderService() {
        return deciderService;
    }

    public void setDeciderService(DeciderService deciderService) {
        this.deciderService = deciderService;
    }

    public static TaskMapperContextBuilder newBuilder() {
        return TaskMapperContextBuilder.aTaskMapperContext();
    }

    public static final class TaskMapperContextBuilder {
        private WorkflowDef workflowDefinition;
        private Workflow workflowInstance;
        private TaskDef taskDefinition;
        private WorkflowTask taskToSchedule;
        private Map<String, Object> taskInput;
        private String taskId;
        private DeciderService deciderService;

        private TaskMapperContextBuilder() {
        }

        public static TaskMapperContextBuilder aTaskMapperContext() {
            return new TaskMapperContextBuilder();
        }

        public TaskMapperContextBuilder withWorkflowDefinition(WorkflowDef workflowDefinition) {
            this.workflowDefinition = workflowDefinition;
            return this;
        }

        public TaskMapperContextBuilder withWorkflowInstance(Workflow workflowInstance) {
            this.workflowInstance = workflowInstance;
            return this;
        }

        public TaskMapperContextBuilder withTaskDefinition(TaskDef taskDefinition) {
            this.taskDefinition = taskDefinition;
            return this;
        }

        public TaskMapperContextBuilder withTaskToSchedule(WorkflowTask taskToSchedule) {
            this.taskToSchedule = taskToSchedule;
            return this;
        }

        public TaskMapperContextBuilder withTaskInput(Map<String, Object> taskInput) {
            this.taskInput = taskInput;
            return this;
        }

        public TaskMapperContextBuilder withTaskId(String taskId) {
            this.taskId = taskId;
            return this;
        }

        public TaskMapperContextBuilder withDeciderService(DeciderService deciderService) {
            this.deciderService = deciderService;
            return this;
        }

        public TaskMapperContext build() {
            TaskMapperContext taskMapperContext = new TaskMapperContext();
            taskMapperContext.workflowInstance = this.workflowInstance;
            taskMapperContext.taskInput = this.taskInput;
            taskMapperContext.taskDefinition = this.taskDefinition;
            taskMapperContext.taskId = this.taskId;
            taskMapperContext.workflowDefinition = this.workflowDefinition;
            taskMapperContext.taskToSchedule = this.taskToSchedule;
            taskMapperContext.deciderService = this.deciderService;
            return taskMapperContext;
        }
    }
}
